const NAMESPACE = '__data__'
export const setStorage = (key: string, value: object) => {
  localStorage.setItem(`${NAMESPACE}@${key}`, JSON.stringify(value))
}

export const getStorage = (key: string) => {
  try {
    const data = localStorage.getItem(`${NAMESPACE}@${key}`)
    return JSON.parse(data) as object
  } catch (err) {
    return null
  }
}
